package com.cqywc.cjadmin.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.cqywc.cjadmin.mapper.MenuMapper;
import com.cqywc.cjadmin.pojo.Menu;
import com.cqywc.cjadmin.pojo.MenuExample;
import com.cqywc.cjadmin.service.MenuService;
@Service
public class MenuSerivceImpl implements MenuService {
	@Autowired
	private MenuMapper menuMapper;
	
	@Override
	public List<Menu> queryList() {
		MenuExample example =new MenuExample();
		example.setOrderByClause(" sort asc ");
		List<Menu> lists = menuMapper.selectByExample(example);
		return lists;
	}

	@Override
	public Integer updateMenu(Menu menu) {
		int row = menuMapper.updateByPrimaryKeySelective(menu);
		return row;
	}

	@Override
	public Integer deleteMenu() {
		return null;
	}

	@Override
	public Menu saveMenu(Menu menu) {
		 menuMapper.insertSelective(menu);
		return null;
	}

	@Override
	public Menu queryById(Integer id) throws Exception {
		 Menu menu = menuMapper.selectByPrimaryKey(id);
		 if(menu.getId()==null) {
			throw new Exception("菜单不存在");
		 }
		return menu;
	}

	



}
